﻿using System.Linq;
using GC_FFW.BusinessEntities.Abstractions.Interfaces.Forecast;
using GC_FFW.BusinessEntities.Forecast.Xml;
using GC_FFW.ForecastWriter.Abstractions.Adapters;
using GC_FFW.ForecastWriter.Abstractions.Interfaces.Helpers;

namespace GC_FFW.ForecastWriter.Adapters.TeamMatch.ConfrontationsStatistics
{
	public class MatchesCountProposalAdapter : ProposalBaseAdapter
	{
		#region Constructors

		public MatchesCountProposalAdapter(IForecastData forecastData, Conditions conditions,
			IStringManager stringManager, IRandomizer randomizer)
			: base(forecastData, conditions, stringManager, randomizer) { }

		#endregion

		#region Overrides

		public override string GetText()
		{
			var countMatches = ForecastData.PersonalConfrontationStatistics != null && ForecastData.PersonalConfrontationStatistics.Matches != null
				? ForecastData.PersonalConfrontationStatistics.Matches.Count()
				: 0;

			var proposal = GetProposal(Conditions.GetCondition(
				countMatches >= 5
					? 1
					: countMatches > 0
						? 2
						: 3));
			return proposal != null && proposal.Text != null ? proposal.Text : string.Empty;
		}

		#endregion
	}
}
